#include "HX711.h"
#include <Servo.h>

Servo servo_11;

HX711 scale1;
HX711 scale2;
HX711 scale3;

uint8_t dataPin1 = 2;  // Adjust the pin numbers based on your actual connections
uint8_t clockPin1 = 3;

uint8_t dataPin2 = 4;
uint8_t clockPin2 = 5;

uint8_t dataPin3 = 6;
uint8_t clockPin3 = 7;

void setup() {
  servo_11.attach(11);
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("LIBRARY VERSION: ");
  Serial.println(HX711_LIB_VERSION);
  Serial.println();

  scale1.begin(dataPin1, clockPin1);
  scale2.begin(dataPin2, clockPin2);
  scale3.begin(dataPin3, clockPin3);

  // Calibration factors for each load cell
  scale1.set_scale(420.0983);  // Calibrate this for the first load cell
  scale2.set_scale(420.0983);  // Calibrate this for the second load cell
  scale3.set_scale(420.0983);  // Calibrate this for the third load cell

  // Tare each scale to zero
  scale1.tare(20);
  scale2.tare(20);
  scale3.tare(20);
}

void loop() {
  delay(100);
  if (scale1.is_ready() && scale2.is_ready() && scale3.is_ready()) {
     //Read weights from each scale and print to Serial
    //Serial.print("Scale 1: ");
    //Serial.print(scale1.get_units(1));
    //Serial.print("\tScale 2: ");
    //Serial.print(scale2.get_units(1));
    //Serial.print("\tScale 3: ");
    //Serial.println(scale3.get_units(1));
    if (scale1.get_units(1) > 400 || (scale2.get_units(1) > 600 || scale3.get_units(1) > 400)) {
      servo_11.write(70);
      delay(1500);
      servo_11.write(90);
      Serial.println('a');
      delay(30000);

    } else {
      Serial.println('h');
    }
  }
}
